<%@ page language="java" pageEncoding="UTF-8"
	contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE>
<html>
<head>
<title>明细信息</title>
	<%@ include file="/resources/js/easyui/taglibs.jsp"%>
	<%@ include file="/resources/js/easyui/_easyui.jsp"%>
	<%@ include file="/resources/js/easyui/_message.jsp"%>
	<%@ include file="/resources/js/easyui/_viewJS.jsp"%>
</head>

<body class="easyui-layout">
	<form id="addform">
		<table class="tableForm" style="width: 100%;">
			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>父级权限：</label></th>
				<td><select class="easyui-combobox easyui-textbox" style="width:200px;"
					name="pmoduleid" data-options="required:true">
						<c:forEach items="${parentModuleList}" var="parent"
							varStatus="status">
							<option value="${parent.moduleid }">${parent.textCN }</option>

							<c:forEach items="${parent.childModules}" var="childModue" varStatus="status">
								<option value="${childModue.moduleid }">-${childModue.textCN }</option>

								<c:forEach items="${childModue.childModules}" var="childModuechild" varStatus="status">
									<option value="${childModuechild.moduleid }">--${childModuechild.textCN }</option>
								</c:forEach>

							</c:forEach>

						</c:forEach>
				</select>

				</td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>权限名称（中文）：</label></th>
				<td><input class="easyui-validatebox easyui-textbox" name="namecn"
					style="width:200px" data-options="required:true,validType:'chinese'" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>权限名称（英文）：</label></th>
				<td><input class="easyui-validatebox easyui-textbox" name="sname"
					style="width:200px" data-options="required:true,validType:'english'" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>url：</label></th>
				<td><input class="easyui-validatebox easyui-textbox" name="url"
					style="width:200px" data-options="required:true" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>权限属性：</label></th>
				<td><input class="easyui-validatebox easyui-textbox" name="attribute" style="width:200px;height:60px"
						data-options="multiline:true"></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>备注：</label></th>
				<td><input class="easyui-textbox" name="remark"
					data-options="multiline:true" style="width:200px;height:60px;"></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>权限作用域：</label></th>
				<td><input type="radio" name="ntype" value="1"
					checked="checked">PC端</input> <input type="radio" name="ntype"
					value="2">微信端</input> <input type="radio" name="ntype" value="3">APP端</input>
					<input type="radio" name="ntype" value="4">操作权限</input>
				</td>
			</tr>

		</table>

	</form>

	<script type="application/javascript">

	function add(){
		if($("#addform").form('validate')){
			$.ajax({
				url:'${basePath}web/module/newModule',
				type : 'POST',
				data : $("#addform").serialize(),
				async : false,
				traditional:true,
				error: function (response) {
					ViewHelper.func.ajaxErrorMessage(response);
				},
				success: function (ret) {
					if(ret.result) {
						$.messager.alert('提示信息！',ret.info,'info');
						parent.view.closeAddWin(1);
						$("#addform").form('clear');
					}else{
						$.messager.alert('提示','保存失败!','error');
					}
				}
			});
		}
	}
	
	$.extend($.fn.validatebox.defaults.rules, {
		chinese: {
			 validator : function(value) {
                 return /^[\u0391-\uFFE5]+$/.test(value);
             },
             message : '请输入正确的中文名称'
		},
		english:{
			validator: function(value){
				return /^[a-zA-Z]+$/.test(value);
			},
			message: '请输入正确的英文名称'
		}
		
	});

	</script>
</body>
</html>
